<!-- 高级 》 单选框 -->

<template>
  <div v-bind="superProps">
    <label v-if="label" v-bind="labelProps">{{ label }}</label>

    <el-button v-if="hasClear" :size="commonProps.size" class="CoreWeb-RadioClear" type="text" @click.stop="toClear">
      {{ clearText }}
    </el-button>

    <el-radio-group
      v-if="isBtn"
      v-model="model"
      v-bind="commonProps"
      :class="`${className} CoreWeb-RadioGroup`"
      @change="emitChange"
    >
      <el-radio-button :label="0">全部</el-radio-button>
      <el-radio-button
        v-for="(item, i) in selectData"
        :key="`${item[0]}-${i}`"
        :label="item[0]"
        :disabled="getDisabled(item)"
      >
        <span class="CoreWeb-radio-btn">
          <slot name="item" :item="item">
            <span>{{ item[1] }}</span>
            <span v-if="showRight" class="CoreWeb-radio-btn-right">{{ item[rightIndex] }}</span>
          </slot>
        </span>
      </el-radio-button>
    </el-radio-group>

    <el-radio-group
      v-else
      v-model="model"
      v-bind="commonProps"
      :class="`${className} CoreWeb-RadioGroup`"
      @change="emitChange"
    >
      <el-radio :label="0">全部</el-radio>
      <el-radio v-for="(item, i) in selectData" :key="`${item[0]}-${i}`" :label="item[0]" :disabled="getDisabled(item)">
        <span class="CoreWeb-radio">
          <slot name="item" :item="item">
            <span>{{ item[1] }}</span>
            <span v-if="showRight" class="CoreWeb-radio-right">{{ item[rightIndex] }}</span>
          </slot>
        </span>
      </el-radio>
    </el-radio-group>
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import mixSuper from '../mixSuper'
import FormRadio from '../../form/FormRadio'

const name = 'SuperRadio'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name,

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [mixSuper],

  /**
   * 属性注册 (抽取以便查阅)
   */
  props: CORE.WEB[name],

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: FormRadio.computed,

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: FormRadio.methods,
}
</script>
